home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Tools - Objects / C++ / MPW C++ 3.1b1 / Examples / CPlusExamples / TECommon.h < prev    next >
Text File  |  1989-09-29  |  7KB  |  173 lines

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple TextEdit Sample Application
  6. #
  7. #    CPlusTESample
  8. #
  9. #    TECommon.h    -    C++ and Rez source
  10. #
  11. #    Copyright © 1989 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #            1.10                     07/89
  16. #            1.00                     04/89
  17. #
  18. #    Components:
  19. #            CPlusTESample.make        July 9, 1989
  20. #            TApplicationCommon.h    July 9, 1989
  21. #            TApplication.h            July 9, 1989
  22. #            TDocument.h                July 9, 1989
  23. #            TECommon.h                July 9, 1989
  24. #            TESample.h                July 9, 1989
  25. #            TEDocument.h            July 9, 1989
  26. #            TApplication.cp            July 9, 1989
  27. #            TDocument.cp            July 9, 1989
  28. #            TESample.cp                July 9, 1989
  29. #            TEDocument.cp            July 9, 1989
  30. #            TESampleGlue.a            July 9, 1989
  31. #            TApplication.r            July 9, 1989
  32. #            TESample.r                July 9, 1989
  33. #
  34. #    CPlusTESample is an example application that demonstrates
  35. #    how to initialize the commonly used toolbox managers,
  36. #    operate successfully under MultiFinder, handle desk
  37. #    accessories and create, grow, and zoom windows. The
  38. #    fundamental TextEdit toolbox calls and TextEdit autoscroll
  39. #    are demonstrated. It also shows how to create and maintain
  40. #    scrollbar controls. 
  41. #
  42. #    This version of TESample has been substantially reworked in
  43. #    C++ to show how a "typical" object oriented program could
  44. #    be written. To this end, what was once a single source code
  45. #    file has been restructured into a set of classes which
  46. #    demonstrate the advantages of object-oriented programming.
  47. #   
  48. ------------------------------------------------------------------------------*/
  49.  
  50. #ifndef TECommon_Defs
  51. #define TECommon_Defs
  52.  
  53. /*
  54.     These definitions are shared by Rez and C++. We use #define statements
  55.     instead of constants in this file because Rez doesn't support constants,
  56.     and since the 3.0b1 version of Rez doesn't like the C++ comments, we use
  57.     C style comments in this file as well.
  58.  */
  59.  
  60. /*    Determining an application's minimum size to request from MultiFinder depends
  61.     on many things, each of which can be unique to an application's function,
  62.     the anticipated environment, the developer's attitude of what constitutes
  63.     reasonable functionality and performance, etc. Here is a list of some things to
  64.     consider when determining the minimum size (and preferred size) for your
  65.     application. The list is pretty much in order of importance, but by no means
  66.     complete.
  67.     
  68.     1.    What is the minimum size needed to give almost 100 percent assurance
  69.         that the application won't crash because it ran out of memory? This
  70.         includes not only things that you do have direct control over such as
  71.         checking for NIL handles and pointers, but also things that some
  72.         feel are not so much under their control such as QuickDraw and the
  73.         Segment Loader.
  74.         
  75.     2.    What kind of performance can a user expect from the application when
  76.         it is running in the minimum memory configuration? Performance includes
  77.         not only speed in handling data, but also things like how many documents
  78.         can be opened, etc.
  79.         
  80.     3.    What are the typical sizes of scraps that a user might wish to work
  81.         with when lauching or switching to your application? If the amount
  82.         of memory is too small, the scrap will be purged from memory. This
  83.         can be quite frustrating to the user.
  84.         
  85.     4.    The previous items have concentrated on topics that tend to cause an
  86.         increase in the minimum size to request from MultiFinder. On the flip
  87.         side, however, should be the consideration of what environments the
  88.         application may be running in. There may be a high probability that
  89.         many users with relatively small memory configurations will want to
  90.         avail themselves of your application. Or, many users might want to use it
  91.         while several other, possibly related/complementary applications are
  92.         running. If that is the case, it would be helpful to have a fairly
  93.         small minimum size.
  94.     
  95.     What we did for CPlusTESample:
  96.     
  97.         We determined the smallest heap size that CPlusTESample could have and
  98.         still run (24K). For the preferred size we added enough space to permit:
  99.             a. a maximum size TextEdit text handle (32000 characters)
  100.             b. a maximum usable TextEdit scrap (32000 characters)
  101.             b. a maximum scrap as a result of Copy (32000 characters)
  102.             d. a little performance cushion (see 2, above) (10K)
  103.         Result: 124K for preferred size
  104.         
  105.         For the minimum size we took the 22K and then scaled down our requirements
  106.         for a,b, and c above. We thought that providing 16K more would be lean
  107.         and mean (see 4, above).
  108.         Result: 40K for minimum size
  109. */
  110.  
  111. #define kPrefSize                124
  112. #define kMinSize                40
  113.     
  114. /* kMinHeap - This is the minimum result from the following
  115.      equation:
  116.             
  117.             ORD(GetApplLimit) - ORD(ApplicZone)
  118.             
  119.      for the application to run. It will insure that enough memory will
  120.      be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  121.      application, and still give the application some 'breathing room'.
  122.      To derive this number, we ran under a MultiFinder partition that was
  123.      our requested minimum size, as given in the 'SIZE' resource. */
  124.      
  125. #define    kMinHeap                 (34 * 1024)
  126.     
  127. /* kMinSpace - This is the minimum result from PurgeSpace, when called
  128.      at initialization time, for the application to run. This number acts
  129.      as a double-check to insure that there really is enough memory for the
  130.      application to run, including what has been taken up already by
  131.      pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  132.      
  133. #define    kMinSpace                (20 * 1024)
  134.  
  135. /* id of our STR# for error strings */
  136. #define kTEDocErrStrings     129
  137.  
  138. /* The following are indicies into STR# resources. */
  139. #define    eNoMemory                1
  140. #define    eNoSpaceCut                2
  141. #define    eNoCut                    3
  142. #define    eNoCopy                    4
  143. #define    eExceedPaste            5
  144. #define    eNoSpacePaste            6
  145. #define    eNoWindow                7
  146. #define    eExceedChar                8
  147. #define    eNoPaste                9
  148.  
  149. #define    rMenuBar    128                /* application's menu bar */
  150. #define    rAboutAlert    128                /* about alert */
  151. #define    rDocWindow    128                /* application's window */
  152. #define    rVScroll    128                /* vertical scrollbar control */
  153. #define    rHScroll    129                /* horizontal scrollbar control */
  154.  
  155. /* The following constants are used to identify menus and their items. The menu IDs
  156.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  157. #define    mApple                    128        /* Apple menu */
  158. #define    iAbout                    1
  159.  
  160. #define    mFile                    129        /* File menu */
  161. #define    iNew                    1
  162. #define    iClose                    4
  163. #define    iQuit                    12
  164.  
  165. #define    mEdit                    130        /* Edit menu */
  166. #define    iUndo                    1
  167. #define    iCut                    3
  168. #define    iCopy                    4
  169. #define    iPaste                    5
  170. #define    iClear                    6
  171.  
  172. #endif TECommon_Defs
  173.